package xyz.xiezc.xsync.server.common;

import lombok.Data;

import java.io.Serializable;

/**
 * @Description 返回对象
 * @Author xiezc
 * @Version 1.0
 * @Date 2020/10/10 5:58 下午
 **/
@Data
public class Result<T> implements Serializable {

    private T data;

    private boolean success = true;

    private int code = 200;

    private String msg;

    private long traceId;

    public static <T> Result<T> success(T data) {
        Result<T> result = new Result<T>();
        result.setData(data);
        return result;
    }

    public static <T> Result<T> fail(int code, String msg) {
        Result<T> result = new Result<T>();
        result.setCode(code);
        result.setMsg(msg);
        result.setSuccess(false);
        return result;
    }


}